import { fileURLToPath, URL } from "node:url";

import { defineConfig } from "vite";
import vue from "@vitejs/plugin-vue";

// 引入自动导入模块插件
import AutoImport from "unplugin-auto-import/vite";

// https://vitejs.dev/config/
export default defineConfig({
  plugins: [
    vue(),
    AutoImport({
      imports: [
        "vue",
        "vue-router",
        // {
        //     "@/api/index":[
        //         ['default','Api']
        //     ]
        // }
      ],
      // dts:"./auto-imports.d.ts"
    }),
  ],
  resolve: {
    alias: {
      "@": fileURLToPath(new URL("./src", import.meta.url)),
      "vue":'vue/dist/vue.esm-bundler.js'
    },
  },
  server: {
    proxy: {
      //设置代理请求 当代理商识别你的请求如果前缀是 /api的话 就会自动转移
      "/shop": {
        // target: "http://www.fast.com:3901/shop",
        target: "https://www.fast.nui.xietao.online/shop",
        changeOrigin: true, //跨域
        //替换掉api前缀 防止多个api地址
        rewrite: (path) => path.replace(/^\/shop/, ""),
      },
    },
    hmr: {
      overlay: false,
    },
  }
});
